package org.fast.easy.auth.listener;

import cn.dev33.satoken.config.SaTokenConfig;
import cn.dev33.satoken.stp.SaLoginModel;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.fast.easy.auth.service.ISysLoginService;
import org.fast.easy.core.domain.auth.model.LoginUser;
import org.fast.easy.core.util.ServletUtils;
import org.fast.easy.framework.satoken.utils.LoginHelper;
import org.springframework.stereotype.Component;

import java.util.concurrent.ScheduledExecutorService;

/**
 * 用户行为 侦听器的实现
 *
 * @author Lion Li
 */
@Component
@Slf4j
public class UserActionListener extends AbstractUserActionListener {
    @Resource
    private SaTokenConfig tokenConfig;
    @Resource
    private ScheduledExecutorService scheduledExecutorService;


    public UserActionListener(SaTokenConfig tokenConfig) {
        super(tokenConfig);
    }

    /**
     * 每次登录时触发
     */
    @Override
    public void doLogin(String loginType, Object loginId, String tokenValue, SaLoginModel loginModel) {
        // 记录登录日志
        doLogininforEvent(tokenValue);
        // 更新登录信息
        LoginUser user = LoginHelper.getLoginUser();


        log.info("user doLogin, useId:{}, token:{}", loginId, tokenValue);
    }

}
